package com.tg.message.adapter;

import android.annotation.SuppressLint;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.NonNull;

import com.appbase.custom.base.MessageFilterBean;
import com.tg.message.R;

import java.util.List;

public class MessageMultiFilterAdapter extends MessageFilterAdapter{

    public MessageMultiFilterAdapter(List<MessageFilterBean> list) {
        super(list);
    }
    @NonNull
    @Override
    public MessageFilterAdapter.MessageDeviceFilterViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
       return super.onCreateViewHolder(parent,viewType);
    }


    @Override
    public void onBindViewHolder(@NonNull MessageFilterAdapter.MessageDeviceFilterViewHolder holder, @SuppressLint("RecyclerView") int position) {
        MessageFilterBean messageFilterBean = list.get(position);
        holder.tvDeviceName.setText(messageFilterBean.name);
        if (mSelectList!=null&&mSelectList.size()>0&&mSelectList.contains(messageFilterBean.event)){
            holder.tvDeviceName.setBackgroundResource(R.drawable.main_rounded_bg);
            holder.tvDeviceName.setTextColor(context.getResources().getColor(R.color.white));
            holder.ivMultiSelected.setVisibility(View.GONE);
        }else {
            holder.ivMultiSelected.setVisibility(View.GONE);
            holder.tvDeviceName.setBackgroundResource(R.drawable.dark_rounded_bg);
            holder.tvDeviceName.setTextColor(context.getResources().getColor(R.color.message_filter_item_text_normal_color));
        }
        holder.tvDeviceName.setOnClickListener(v -> {
            if (clickListener!=null){
                clickListener.onItemClick(position,mFilterType);
            }
        });
    }
}
